﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>查找会员</title>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css"> 
        .allContent{ width:1000px; margin:0px auto;}
      .ShowError{  color:Red; visibility:hidden;}
      .ShowSerachData{overflow:scroll; margin-top:30px; }
      .#showX{ border-color:#1C1C1C; height: 100%; width:100%;overflow:scroll;text-align:center; border-collapse:collapse; border-spacing:0; margin-bottom:10px;}
      #showX th,td{ word-break:keep-all; white-space:nowrap;  border:1px black solid ; padding:3px;}
      input[ type="text"]{width:150px;border:none; border-bottom:solid 1px #ccc; height:18px; line-height:18px; font-size:12px;  padding:1px 2px 1px 2px;}
    </style>
</head>
<body class="main">
  <div class="AllWebTopDiv">
     <div class="path">
             <div class="nav">
               <a href="#">查找会员</a>
             </div>
        </div>
       <div class="content">
        <div class="allContent">
        <div class="SelectMenu">
           <label>会员编号：</label>
           <input  type="text" id="memberId"/>
           <label>姓名：</label>
           <input  type="text" id="memberName"/>
           <input  type="button" value="查找" class="button2"  onclick="SearchData();" />
           <input  type="button" value="关闭" onclick="closeWindows();" class="button2"/>
           <br />

           <label>手机号码：</label>
           <input  type="text" id="mobile" />
           <input  type="button" value="添加条件" onclick="AddTiaoJian();" class="button2"/><span class="ShowError">只能添加3个条件</span>
        </div>
         <div class="ShowSerachData" >
          <table id="showX">
     
          </table>
         </div>
      </div>
    </div>
   
    </div>
</body>
</html>
<script type="text/javascript">
    var tiaojian = 1;
    function AddTiaoJian() {

        switch (tiaojian) {
            case 1:
                $(".SelectMenu").append("<br/><div class=\"div1\"> <label>条件一：</label> <select id=\"select_" + tiaojian + "\"><option value=\"Tel\" >联系电话</option><option value=\"sex\">性别</option><option value=\"IDNumber\">身份证号</option><option value=\"Email\">电子邮箱</option> </select>：<input  type=\"text\" id=\"tiaojian" + tiaojian + "\"/> <input type=\"button\" value=\"删除\" class=\"button2\" onclick='DeleteDiv(1)'> </div>");
                tiaojian += 1;
                break;
            case 2:
                $(".SelectMenu").append(" <div class=\"div2\"><label>条件二：</label> <select id=\"select_" + tiaojian + "\"><option value=\"Tel\" >联系电话</option><option value=\"sex\">性别</option><option value=\"IDNumber\">身份证号</option><option value=\"Email\">电子邮箱</option> </select>：<input  type=\"text\" id=\"tiaojian" + tiaojian + "\"/> <input type=\"button\" value=\"删除\" class=\"button2\" onclick='DeleteDiv(2)'></div>");
                tiaojian += 1;
                break;
            case 3:
                $(".SelectMenu").append("<div class=\"div3\"> <label>条件三：</label> <select id=\"select_" + tiaojian + "\"><option value=\"Tel\" >联系电话</option><option value=\"sex\">性别</option><option value=\"IDNumber\">身份证号</option><option value=\"Email\">电子邮箱</option> </select>：<input  type=\"text\" id=\"tiaojian" + tiaojian + "\"/> <input type=\"button\" value=\"删除\" class=\"button2\" onclick='DeleteDiv(3)'></div>");
                tiaojian +=1;
                break;

            default:
                $(".ShowError").css("visibility", "visible");
                break;
          
        }       
 }


 function DeleteDiv(o) { 
       var last=parseInt(tiaojian)-1; 
      if(last!=parseInt(o)){
        
        if(parseInt(last)==2){ 
         alert("请先删除条件二");
          return false;
         }
         if(parseInt(last)==3){ 
         alert("请先删除条件三");
          return false;
         }
        
      }
     switch (o) {
         case 1:
             $(".div1").remove();
             $(".ShowError").css("visibility", "hidden");
             tiaojian--;
             break;
         case 2:
             $(".div2").remove();
             $(".ShowError").css("visibility", "hidden");
             tiaojian--;
             break;
         case 3:
             $(".div3").remove();
             $(".ShowError").css("visibility", "hidden");
             tiaojian--;
             break;
         
         default:
             alert("出错误了！");
             break;
     }

 }

 function SearchData() {

     var memberId = $("#memberId").val();
     var memberName = $("#memberName").val();
     var mobile = $("#mobile").val();
     if ($("#tiaojian1").length > 0) {
         var select1Index = document.getElementById("select_1").selectedIndex;
         var select1 = document.getElementById("select_1").options[select1Index].value;
         var tiaojian1=$("#tiaojian1").val();
     }
     if ($("#tiaojian2").length > 0) {
         var select2Index = document.getElementById("select_2").selectedIndex;
         var select2 = document.getElementById("select_2").options[select2Index].value;
          var tiaojian2=$("#tiaojian2").val();
     }
     if ($("#tiaojian3").length > 0) {
         var select3Index = document.getElementById("select_3").selectedIndex;
         var select3 = document.getElementById("select_3").options[select3Index].value;
          var tiaojian3=$("#tiaojian3").val();
     }

     $.ajax({
            type:"POST",
            url:"<%:Url.Action("Select","SelectMember") %>",
            data:"memberId="+memberId+"&memberName="+memberName+"&mobile="+mobile+"&select1="+select1+"&tiaojian1="+tiaojian1+"&select2="+select2+"&tiaojian2="+tiaojian2+"&select3="+select3+"&tiaojian3="+tiaojian3+"",
            cache:false,
            success:function(txt)
            {
              $("#showX").html(txt);
     
            }  
        })
 }

    //关闭窗口
    function closeWindows() {
        window.location.href = "/Loading/Index/?src=/Desktop/Index/";
    }
</script>
